package hms.rewards;

import java.sql.*;
import java.util.Arrays;
import java.util.Iterator;

import hms.database.*;

/*This class controls all interactions with 
 * Reward_Program table in DB
 * 
 * @author Edgar Onukwugha*/

public class RewardProgram extends DBRowObject {

	private String reward_company;
	
	public RewardProgram(){
		super();
		reward_company = "NONE";
	}
	
	public RewardProgram(int reward_program_ID){
		super(reward_program_ID);
	}
	
	/////////////////////////////////////////////////
	/////               SETTERS                //////
	/////////////////////////////////////////////////
		
	public void setRewardCompany(String i){
		this.reward_company = i;
		markAsChanged();
	}
	
	/////////////////////////////////////////////////
	/////               GETTERS                //////
	/////////////////////////////////////////////////
	
	public String getRewardCompany(){
		return reward_company;
	}
	
	@Override
	protected String[] getFieldNames() {
		String[] output = new String[1];
		output[0] = "REWARD_COMPANY";
				
		return output;
	}

	@Override
	protected void loadPreparedStatement(PreparedStatement stmt)
			throws SQLException {
		stmt.setString(1, reward_company);
		
	}

	@Override
	protected String getUniqueIdentifierFieldName() {
		// TODO Auto-generated method stub
		return "REWARD_PROGRAM_ID";
	}

	@Override
	protected String getTableName() {
		// TODO Auto-generated method stub
		return "REWARD_PROGRAM";
	}

	@Override
	protected void loadFromDatabase(ResultSet rs) throws SQLException {
		Iterator<String> i = Arrays.asList(getFieldNames()).iterator();
		reward_company = rs.getString(i.next());
	}

	@Override
	protected boolean allowDuplicateRows() {
		// TODO Auto-generated method stub
		return false;
	}

}
